#include<iostream>
#include "clutil.h"
using namespace std;

//#define SIZE 1048576
#define SIZE 16777216
//#define SIZE 33554432
//#define SIZE 67108864
//#define SIZE 134217728
//#define SIZE 268435456
//#define SIZE 536870912

#define POINTS_PER_THREAD 16

int
main(int argc, char* argv[])
{

    int size = SIZE;    
    initExecution(size);
    compileProgram("", "kernel.cu");

    createKernel("sum");
    


	allocateDeviceMemory(size);
	clSetKernelArg(kernel, 0, sizeof(cl_mem), (void*) &dA);
	clSetKernelArg(kernel, 1, sizeof(cl_mem), (void*) &dB);
	clSetKernelArg(kernel, 2, sizeof(cl_mem), (void*) &dResult);
   
    
    size_t szLocalWorkSize =  256 ;
    size_t szGlobalWorkSize = size / POINTS_PER_THREAD;
      runKernel(szLocalWorkSize, szGlobalWorkSize);
    copyFromDevice(dResult, hResult, size);
    
    // wait for copy event
    cl_int ciErrNum = clWaitForEvents(1, &gpuDone);
    checkError(ciErrNum, "clWaitForEvents");
    printGpuTime();
    verifyResult(size);
    cleanup();
}

